// D:\Postdoc\ProteinVistaVer2\ProteinVista\ProteinVistaSource\DotNetSettingDialog.cpp : implementation file
//

#include "stdafx.h"
#include "ProteinVista.h"
#include "DotNetSettingDialog.h"


// CDotNetSettingDialog dialog

IMPLEMENT_DYNAMIC(CDotNetSettingDialog, CDialog)

CDotNetSettingDialog::CDotNetSettingDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CDotNetSettingDialog::IDD, pParent)
{
	m_bDebugInformation = FALSE;
}

CDotNetSettingDialog::~CDotNetSettingDialog()
{
}

void CDotNetSettingDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Check(pDX, IDC_CHECK_DEBUG_INFO, m_bDebugInformation);
}

BEGIN_MESSAGE_MAP(CDotNetSettingDialog, CDialog)
	ON_BN_CLICKED(IDC_BUTTON_DEFAULT, &CDotNetSettingDialog::OnBnClickedButtonDefault)
END_MESSAGE_MAP()


// CDotNetSettingDialog message handlers

BOOL CDotNetSettingDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 
	CString	strAssemblies;
	for ( INT32 i = 0 ; i < m_strArrayAssemblies.GetSize() ; i++ )
	{
		strAssemblies += m_strArrayAssemblies[i];
		strAssemblies += _T("\r\n");
	}

	SetDlgItemText(IDC_EDIT_ASSEMBLIES, strAssemblies);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CDotNetSettingDialog::OnOK()
{
	CString	strAssemblies;
	GetDlgItemText(IDC_EDIT_ASSEMBLIES, strAssemblies);

	m_strArrayAssemblies.RemoveAll();

	CString	resToken;
	INT32 curPos = 0;

	resToken= strAssemblies.Tokenize(_T("\n"),curPos);
	while (resToken != _T(""))
	{
		resToken.TrimLeft(_T("\r\n "));
		resToken.TrimRight(_T("\r\n "));
		if ( resToken.IsEmpty() != TRUE )
			m_strArrayAssemblies.Add(resToken);
		resToken = strAssemblies.Tokenize(_T("\n"), curPos);
	};   

	CDialog::OnOK();
}

void CDotNetSettingDialog::OnBnClickedButtonDefault()
{
	CStringArray	strArrayAssemblies;
	strArrayAssemblies.Add("mscorlib.dll");
	strArrayAssemblies.Add("System.dll"); 
	strArrayAssemblies.Add("System.Windows.Forms.dll"); 
	strArrayAssemblies.Add("System.Drawing.dll"); 
	strArrayAssemblies.Add("System.xml.dll"); 

	TCHAR buffWin[MAX_PATH];
	GetWindowsDirectory(buffWin, MAX_PATH);
	CString strWinPath(buffWin);

	CString directXPath = strWinPath + _T("\\assembly\\GAC\\Microsoft.DirectX\\1.0.2902.0__31bf3856ad364e35\\Microsoft.DirectX.dll");
	CString direct3DPath = strWinPath + _T("\\assembly\\GAC\\Microsoft.DirectX.Direct3D\\1.0.2902.0__31bf3856ad364e35\\Microsoft.DirectX.Direct3D.dll");

	strArrayAssemblies.Add(directXPath);
	strArrayAssemblies.Add(direct3DPath);

	CString	strAssemblies;
	for ( INT32 i = 0 ; i < strArrayAssemblies.GetSize() ; i++ )
	{
		strAssemblies += strArrayAssemblies[i];
		strAssemblies += _T("\r\n");
	}

	SetDlgItemText(IDC_EDIT_ASSEMBLIES, strAssemblies);

}
